Skip to main content

All Questions

1vote
1answer
10kviews

jq: error (at input.json:45): Cannot index array with string "value"

I try to convert my .json files to .csv with jq. I'm getting cannot index array with string value on all my values. .json { "organic_data": [ { "description": "...
pwrsheller's user avatar
-1votes
2answers
467views

How do you count the number of tokens from two columns of words from a csv file inside a loop?

I have a comma-separated csv file with 50 lines. One column is for state names and the other column is for capitals (of the states). How do you make a loop where it counts the number of tokens (2, 3, ...
usuallystuck's user avatar
1vote
1answer
112views

AWK: Add missing lines in csv file and set specific column to "0"

(Note: this question is heavily shortened because the detailed question was blocked with "This looks like spam.") I'm having a hard time adding missing lines to a series of data in a ...
JuliusCaesar's user avatar
2votes
1answer
46views

Loop through file with unique identifer and compute cumulative sum

I have a large text file, as shown below, where column1-colum3 define a region and fourth column is unique identifier. The column 6 is assigned value of the region. chr6 26204834 26204839 ...
CN_229133's user avatar
1vote
1answer
1kviews

Access element of array

I have the following script which retrieves info from mysql #!/bin/bash set -f IFS=$'\n' arr=($(sudo mysql -u root -h localhost -e "USE mydb;SELECT * FROM users")) for i in "${...
Iosef's user avatar
0votes
2answers
741views

Filtering rows of a dataframe with AWK to only show entries in a given field with X instances

I have a large dataframe, in which one of the fields("ID") correspond to a unique identifier. However, there are multiple instances of that value, depending on the binary combination of additional ...
ricardo3889's user avatar
0votes
1answer
183views

I would like to analyze a TXT file, but the data is a 1 column array, and it needs to be a in a multi-column array

Is there a way for me to manipulate the data (i.e.; change some feature of, so that it looks like it should, a multi-column array) without having to manually go through it? There are thousands of rows ...
Ctat41's user avatar
2votes
1answer
355views

How to extract data more Efficient in an array?

I have a directory with some text files that have data like below; I read them via a loop and put each line in an array! I don't know the correct way and if you know any better way, let me know. ...
amkyp's user avatar
0votes
2answers
8kviews

bash syntax error: invalid arithmetic operator (error token is ".google.com") when parsing through array

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error line ...
john doe's user avatar
1vote
1answer
856views

Reading multiple files and operating on stored Arrays

I have 2 text files "${LinkP}" and "${QuestionP}. I want to read these files and store each complete line in the respective array, IFS=$'\r\n' GLOBIGNORE='*' command eval "LinkA=($(cat "${LinkP}"))" ...
Porcupine's user avatar
0votes
1answer
774views

bash script load an modify array from external file

I have written a script that is reading an array: recentdirs with directory names from an external config file called: defaults.cfg and the user can either chose one of the directories from the list ...
Eike's user avatar
  • 153
1vote
1answer
837views

How to give multidimensional array a value for each 'cells'

I'm not a programmer at all, but I need to write a script to cut a file and produce a multidimensional array from this file. I'm a chemist, so my array should be something like: [pe][pH][element][...
Nicolas Schmitt's user avatar
12votes
4answers
28kviews

Print all words on lines of a file in reverse order

I don't know how to make my code working for more lines. This is the original file t.txt: Hello Earth Hello Mars But I get the following output: Mars Hello Earth Hello My expected output is this: ...
Bersekz's user avatar
2votes
2answers
828views

bash - Separate "table" values into strings in array

EDIT: I'm sorry, the output I claimed is wrong. There are more spaces than I previously thought (something happened when the output was saved to html file to remove these) The real output is as ...
L.Johnson's user avatar
0votes
1answer
529views

Reading decimals in text file into a 1D array [closed]

So I have this text file named sortedtime.txt containing sorted decimals and integers listed line by line: 12.6 13.7 ... 154 1864 I need a shell script that will read these numbers and add ...
user192314's user avatar

153050per page
close